/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.home.gui;

import com.home.common.ApplicationCommon;
import com.home.common.LevelSubject;
import com.home.components.ModalJInternalFrame;

/**
 *
 * @author vi
 */
public class ChooserLevelSubject extends ModalJInternalFrame {
    private QualityReport qualityReport;
    int selectedLevel = LevelSubject.SUBJECT_LEVEL_1;
    /**
     * Creates new form ChooserLevelSubject
     */
    public ChooserLevelSubject(QualityReport qualityReport) {
        initComponents();
        this.setModal(true);
        setBounds(ApplicationCommon.getRectangleForCenter(qualityReport.getSize().width, qualityReport.getSize().height, this.getWidth(), this.getHeight()));
        this.qualityReport = qualityReport;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        radLevel1 = new javax.swing.JRadioButton();
        radLevel2 = new javax.swing.JRadioButton();
        radLevel3 = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        btnChooser = new javax.swing.JButton();

        setTitle("Choose Level");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Level"));

        buttonGroup1.add(radLevel1);
        radLevel1.setSelected(true);
        radLevel1.setText("Level 1");
        radLevel1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radLevel1ActionPerformed(evt);
            }
        });

        buttonGroup1.add(radLevel2);
        radLevel2.setText("Level 2");
        radLevel2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radLevel2ActionPerformed(evt);
            }
        });

        buttonGroup1.add(radLevel3);
        radLevel3.setText("Level 3");
        radLevel3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radLevel3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(radLevel1)
                    .addComponent(radLevel2)
                    .addComponent(radLevel3))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(radLevel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(radLevel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(radLevel3))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Command"));

        btnChooser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icon/btn_ok.png"))); // NOI18N
        btnChooser.setText("Choose");
        btnChooser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChooserActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(0, 269, Short.MAX_VALUE)
                .addComponent(btnChooser))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnChooser)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void radLevel1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radLevel1ActionPerformed
        selectedLevel = LevelSubject.SUBJECT_LEVEL_1;
    }//GEN-LAST:event_radLevel1ActionPerformed

    private void radLevel2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radLevel2ActionPerformed
        selectedLevel = LevelSubject.SUBJECT_LEVEL_2;
    }//GEN-LAST:event_radLevel2ActionPerformed

    private void radLevel3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radLevel3ActionPerformed
        selectedLevel = LevelSubject.SUBJECT_LEVEL_3;
    }//GEN-LAST:event_radLevel3ActionPerformed

    private void btnChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooserActionPerformed
        qualityReport.setSelectedLevelSubject(selectedLevel);
        this.dispose();
    }//GEN-LAST:event_btnChooserActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnChooser;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JRadioButton radLevel1;
    private javax.swing.JRadioButton radLevel2;
    private javax.swing.JRadioButton radLevel3;
    // End of variables declaration//GEN-END:variables
}
